package leetcode.weekly.week310;

import java.util.HashMap;
import java.util.Map;

//Solution1Test
public class Solution1 {

	public int mostFrequentEven(int[] nums) {
		Map<Integer, Integer> map = new HashMap<>();
		int time = 0, value = -1;
		for (int i : nums) {
			if ((i & 1) == 0) {
				map.put(i, map.getOrDefault(i, 0) + 1);
				int cur = map.get(i);
				if (cur > time) {
					value = i;
					time = cur;
				} else if (cur == time) {
					if (i < value) {
						value = i;
					}
				}
			}
		}
		return value;
	}

}
